package net.jumpengine.event;

import java.util.HashMap;
import java.util.Map;

import javafx.scene.input.KeyCode;
import net.jumpengine.Manager;
import net.jumpengine.inter.IInputEvent;

public class KeyMiddle {
	private Map<Enum<?>,IInputEvent> map=new HashMap<>();

	public void pressed(String character, KeyCode code, String text) {
		IInputEvent inputEvent=map.get(Manager.getState());
		if(inputEvent==null) {
			Manager.getLog().error("KeyMiddle[pressed] state:", Manager.getState()," inputEvent为null");
			return;
		}
		inputEvent.pressed(character, code,text);
		
	}

	public void released(String character, KeyCode code, String text) {
		IInputEvent inputEvent=map.get(Manager.getState());
		if(inputEvent==null) {
			Manager.getLog().error("KeyMiddle[released] state:", Manager.getState()," inputEvent为null");
			return;
		}
		inputEvent.released(character, code,text);
	}

	public void typed(String character, KeyCode code, String text) {
		IInputEvent inputEvent=map.get(Manager.getState());
		if(inputEvent==null) {
			Manager.getLog().error("KeyMiddle[typed] state:", Manager.getState()," inputEvent为null");
			return;
		}
		inputEvent.typed(character, code,text);
	}

	public void put(Enum<?> t, IInputEvent event) {
		map.put(t, event);
	}

	public IInputEvent get(Enum<?> e) {
		return map.get(e);
	}
}
